package com.farm.decorator;

import com.farm.AgriculturalMachine;

// 装饰器模式使用示例
public class DecoratorPatternDemo {
    public static void main(String[] args) {
        String  machineName = "播种机A";
        // 创建基本农机
        AgriculturalMachine basicSeeder = new BasicAgriculturalMachine("播种机");
        System.out.println(basicSeeder.getDescription());
        basicSeeder.operate(machineName);

        System.out.println("\n--- 添加GPS功能 ---");
        AgriculturalMachine gpsSeeder = new GPSDecorator(basicSeeder);
        System.out.println(gpsSeeder.getDescription());
        gpsSeeder.operate(machineName);

        System.out.println("\n--- 添加自动驾驶功能 ---");
        AgriculturalMachine autoPilotSeeder = new AutoPilotDecorator(gpsSeeder);
        System.out.println(autoPilotSeeder.getDescription());
        autoPilotSeeder.operate(machineName);

        System.out.println("\n--- 添加土壤分析功能 ---");
        AgriculturalMachine fullFeaturedSeeder = new SoilAnalysisDecorator(autoPilotSeeder);
        System.out.println(fullFeaturedSeeder.getDescription());
        fullFeaturedSeeder.operate(machineName);
    }
}
